package com.gj.spartprice.controller;

import com.gj.spartprice.mapper.SpartPriceMapper;
import com.gj.spartprice.model.FactoryVo;
import com.gj.spartprice.model.SpartPriceAddVo;
import com.gj.spartprice.model.SpartPriceServiceVo;
import com.gj.spartprice.model.SpartPriceVo;
import com.gj.spartprice.service.SpartPriceService;
import com.gj.utli.ResultBuilderVo;
import com.gj.utli.ResultVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by Tangyunhen on 2021-07-05.
 */
@RestController
@CrossOrigin       //跨域
public class SpartPriceController {

         @Autowired
         private SpartPriceService spartPriceService ;

         @PostMapping("/materialCostPrice/queryPage")
         public ResultVo queryPage(@RequestBody SpartPriceServiceVo spartPriceServiceVo){
         return spartPriceService.queryPage(spartPriceServiceVo);
    }
/*
           @PostMapping("/materialCostPrice/add")
          public ResultVo add(@RequestBody @Valid SpartPriceAddVo spartPriceAddVo, BindingResult bindingResult){
             if (bindingResult.hasErrors()){
                    return ResultBuilderVo.error(bindingResult.getFieldError().getDefaultMessage());
             }
                return spartPriceService.add(spartPriceAddVo);
          };*/
//根据法人调出工厂编码
         @Autowired
         private SpartPriceMapper spartPriceMapper;
         @GetMapping("/materialCostPrice/queryPlantListByLegalPersonCode")
         public ResultVo legalpantCodeLike(String legalpersonCode,String legalPlantCode){
             List<FactoryVo> factoryVoList= spartPriceMapper.queryByCodeLike(legalpersonCode,legalPlantCode);
              return ResultBuilderVo.success(factoryVoList);
         }
   //价格分类、币别、当前状态下拉列表三个下拉框
  /* @PostMapping("/metadata/getPullDownList")
    public ResultVo getPullDownList( ){
        ResultVo  resultVo = spartPriceService.getPullDownList();
        return resultVo;
    }*/
         //备件编码查询接口
        /* @GetMapping("querySpartprice")
          public ResultVo querySpartprice(String spartCode){
           List<FactoryVo> factoryVoList= spartPriceMapper.querySpartprice(spartCode);
           return ResultBuilderVo.success(factoryVoList);
    }*/


}
